# -*- coding: utf-8 -*-
"""
Created on Sun Jul 13 07:49:25 2014

@author: kelvin
"""

seq = ['one', 'two', 'three']
for i,element in enumerate(seq):
    seq[i]='%d: %s' %(i, seq[i])
print seq


def fib():
    a,b=0,1
    while True:
        yield b
        a,b=b,a+b
        
f = fib()
print f.next()
print f.next()
print f.next()

print [f.next() for i in range(10)]

def my_generator():
    try:
        yield 'something'
    except ValueError:
        yield 'dealing with the exception'
    finally:
        print 'ok let us clean'
        
gen = my_generator()
print gen.next()
print gen.throw(ValueError('mean mean mean'))
print gen.close()



